package types
import (
"crypto/rand"
"github.com/jcmturner/gofork/encoding/asn1"
"github.com/jcmturner/gokrb5/v8/crypto/etype"
)
type EncryptedData struct {
EType int32 `asn1:"explicit,tag:0"`
KVNO int `asn1:"explicit,optional,tag:1"`
Cipher []byte `asn1:"explicit,tag:2"`
}
type EncryptionKey struct {
KeyType int32 `asn1:"explicit,tag:0"`
KeyValue []byte `asn1:"explicit,tag:1" json:"-"`
}
type Checksum struct {
CksumType int32 `asn1:"explicit,tag:0"`
Checksum []byte `asn1:"explicit,tag:1"`
}
func (a *EncryptedData ) Unmarshal (b []byte ) error {
_ , err := asn1 .Unmarshal (b , a )
return err
}
func (a *EncryptedData ) Marshal () ([]byte , error ) {
edb , err := asn1 .Marshal (*a )
if err != nil {
return edb , err
}
return edb , nil
}
func (a *EncryptionKey ) Unmarshal (b []byte ) error {
_ , err := asn1 .Unmarshal (b , a )
return err
}
func (a *Checksum ) Unmarshal (b []byte ) error {
_ , err := asn1 .Unmarshal (b , a )
return err
}
func GenerateEncryptionKey (etype etype .EType ) (EncryptionKey , error ) {
k := EncryptionKey {
KeyType : etype .GetETypeID (),
}
b := make ([]byte , etype .GetKeyByteSize (), etype .GetKeyByteSize ())
_ , err := rand .Read (b )
if err != nil {
return k , err
}
k .KeyValue = b
return k , nil
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .